<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class NewModel extends BaseModel
{

   var $table  = 'content';	

    var $_page_rows = 10;	
	
    function show($order='',$v='',$word='',$cat = '')
    {  
	     empty($order)?$order = 'A.add_time desc':'';
		 
		 $conditions = "A.lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ";
		 
   	     empty($cat)?$conditions .= " and A.user_id >0 ":$conditions .= " and A.cat_id =$cat and A.user_id >0 ";
		 
		 foreach($word as $key => $value)
		 {

		     if($value)
		     {
		      $conditions .= " and C.title like '%{$value}%' ";
	  
		     }
		 }	
		  

	     $table = $this->table.' A LEFT JOIN '.$this->_prefix.'content_1'.' C ON A.id=C.con_id ';
	  

		 $info['page'] = $this->Page(array('table'=>"{$table}",'conditions' =>"{$conditions}",'url' => '?app=new&act=index&cat='.$cat));		
		 
		 $info['data'] = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' A.*,C.* ','conditions' =>"{$conditions}",'order' =>"{$order}",'limit' =>$info['page']['sql_limit']));
    
		 return $info;
   
    }


    function isindex()
    {    
	    
         $order = 'A.add_time desc';
		 
	     $table = $this->table.' A LEFT JOIN '.$this->_prefix.'content_1'.' C ON A.id=C.con_id ';
	  
		 $info = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' A.*,C.* ','conditions' =>"A.is_show=1 and A.is_index=1 and A.user_id >0  and A.lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'order' =>"{$order}",'return' =>'one'));
    
		 return $info;
        
    }


    function inindex()
    {	    
         $order = 'A.add_time desc';		 
	     $table = $this->table.' A LEFT JOIN '.$this->_prefix.'content_1'.' C ON A.id=C.con_id ';	  
		 $info = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' A.*,C.* ','conditions' =>"A.is_show=1 and A.is_index=1  and A.table_id=1  and A.user_id >0  and A.lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'order' =>"{$order}",'limit' =>10));    
		 return $info;        
    }



    function oneshow($id ='')
    {	    

	     $table = $this->table.' A LEFT JOIN '.$this->_prefix.'content_1'.' C ON A.id=C.con_id ';
	  
		 $info = $this->S_Sql_Exe(array('table'=>"{$table}",'fields'=> ' A.*,C.* ','conditions' =>"A.id='{$id}' and A.user_id >0  and A.lang_type='".trim($GLOBALS['Lang']->_lang_tp)."' ",'return' =>'one'));    
		 return $info;
        
    }

    function vistnumadd($id='')
    {    
		 
		$sql='update '.$this->table.' set visit_num = visit_num + 1 where id = '.intval($id);
		$query = $this->db->query($sql);     
		return true;
    }


}

?>